<!DOCTYPE html> <!-- -*- html -*- -->
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1">
  <title>Row Reducing a Matrix</title>
  <link rel="shortcut icon" href="img/gatech.gif"/>

  
    <link rel="stylesheet" href="css/slideshow.css?vers=c31d27">


  <style>
      
  body {
      text-align: center;
      margin: 0;
      background: white;
  }

  #mathbox {
      width: 800px;
      height: 300px;
      margin: 0;
      border: 0;
      position: relative;
      display: inline-block;
  }

  .centered {
      width: 800px;
      display: inline-block;
  }

  .my-turn {
      width: 30%;
      text-align: center;
  }

  </style>

</head>
<body>
    
    <div id="mathbox"></div>
    <div class="centered">
        <div class="slideshow rrmat">
            <div class="controls">
                <span class="control-button">
                    <span class="icon-arrow prev-button inactive">
                        <span></span><span></span>
                    </span>
                </span>
                <span class="control-button">
                    <span class="icon-repeat reload-button inactive">
                        <span></span><span></span><span></span><span></span>
                    </span>
                </span>
                <span class="control-button" id="next-button">
                    <span class="icon-arrow next-button">
                        <span></span><span></span></span>
                </span><br>
                <span class="pages"></span>
            </div>
            <div class="caption">Let's row reduce this matrix.</div>
        </div>
        <div class="my-turn">
            <button class="slideshow-button">
                Let me take it from here.
            </button>
        </div>
    </div>


    
    <script src="js/slideshow.js?vers=774162"></script>


    <script type="text/javascript">
        "use strict";
        DomReady.ready(function() {

        var augment, blink, camera, height, mathbox, ortho, three, view, width;

ortho = 10000;

width = 800;

height = 300;

mathbox = window.mathbox = mathBox({
  element: document.getElementById("mathbox"),
  size: {
    width: width,
    height: height
  },
  plugins: ['core'],
  mathbox: {
    warmup: 2,
    splash: true,
    inspect: false
  },
  splash: {
    fancy: true,
    color: "blue"
  },
  camera: {
    near: ortho / 4,
    far: ortho * 4,
    lookAt: -width / 4
  }
});

if (mathbox.fallback) {
  throw "WebGL not supported";
}

three = mathbox.three;

three.renderer.setClearColor(new THREE.Color(0xFFFFFF), 1.0);

camera = mathbox.camera({
  proxy: false,
  position: [0, 0, ortho],
  fov: Math.atan(height / ortho) * 360 / π,
  lookAt: [width / 4, 0, 0]
});

view = mathbox.cartesian({
  range: [[-width / 2, width / 2], [-height / 2, height / 2], [-50, 50]],
  scale: [width, height, 100]
});

mathbox.set('focus', ortho);

window.rrmat = new RRMatrix(3, 4, view, mathbox, {
  augmentCol: 2,
  startAugmented: true
});

window.blink = blink = function(color, entries, times) {
  var arr, delay, i, k, last, ref;
  if (!times) {
    times = 2;
  }
  arr = [];
  delay = 0;
  for (i = k = 0, ref = times; 0 <= ref ? k < ref : k > ref; i = 0 <= ref ? ++k : --k) {
    arr.push({
      color: color,
      transform: "scale(2,2)",
      entries: entries,
      duration: 0.4,
      delay: delay
    });
    delay += 0.4;
    last = {
      color: "black",
      transform: "",
      entries: entries,
      duration: 0.4,
      delay: delay
    };
    delay += 0.4;
    arr.push(last);
  }
  delete last.color;
  return arr;
};

augment = null;

rrmat.setMatrix([[0, -7, -4, 2], [2, 4, 6, 12], [3, 1, -1, -2]]);

window.slideshow = rrmat.slideshow().caption("<b>Step 1a:</b> These are the pivots in the first column.").setStyle(blink("red", [[1, 0], [2, 0]])).caption("<b>Step 1a:</b> These are the pivots in the first column." + " We need to move one of them to the first row.")["break"]().setStyle({
  color: "black",
  entries: [[2, 0]],
  duration: 0.2
}).rowSwap(0, 1)["break"]().caption("<b>Step 1b:</b> Make this entry a 1 by dividing by 2.").setStyle(blink("red", [[0, 0]], 1)).rowMult(0, 1 / 2)["break"]().caption("Let's get rid of this distracting line.").unAugment()["break"]().caption("<b>Step 1c:</b> We kill this entry...").setStyle(blink("blue", [[2, 0]], 1)).caption("<b>Step 1c:</b>" + " We kill this entry by subtracting 3 times the first row.").rowRep(0, -3, 2).setStyle({
  color: "black",
  entries: [[2, 0]],
  duration: 0.2
})["break"]().caption("Now that the first column is clear except for the pivot in\nthe first row, we can ignore the first row and the first\ncolumn and concentrate on the rest of the matrix.").setStyle({
  color: "rgb(200,200,200)",
  entries: [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [2, 0]],
  duration: 0.5
})["break"]().caption("<b>Step 2a</b> (optional):\nBoth of the remaining entries in\nthe second column are pivots.").setStyle(blink("red", [[1, 1], [2, 1]]))["break"]().caption("<b>Step 2a</b> (optional):\nWe'll use the bottom entry as our pivot...").setStyle({
  color: "black",
  entries: [[1, 1]],
  duration: 1
}).caption("<b>Step 2a</b> (optional):\nWe'll use the bottom entry as our pivot,\nso we have to switch rows.").rowSwap(1, 2)["break"]().caption("<b>Step 2b:</b> Divide row 2 by -5 to make this pivat a 1.").rowMult(1, -1 / 5).caption("<b>Step 2b:</b> Divide row 2 by -5 to make this pivat a 1.\n(The other entries in this row are divisible by 5; that's why we\nused this row as the pivot row.)")["break"]().caption("<b>Step 2c:</b> To kill this entry...").setStyle(blink("blue", [[2, 1]], 1)).caption("<b>Step 2c:</b>\nTo kill this entry, we add 7 times row 2 to row 3.").rowRep(1, 7, 2).setStyle({
  color: "black",
  entries: [[2, 1]],
  duration: 0.2
})["break"]().caption("Now the second column (the part we care about) is clear\nexcept for the pivot in the pivot, so we can ignore the\nsecond column and second row.").setStyle({
  color: "rgb(200,200,200)",
  entries: [[1, 1], [1, 2], [1, 3], [2, 1]],
  duration: 1
})["break"]().caption("<b>Step 3a:</b>\nThe first nonzero entry of the last row is a pivot.").setStyle(blink("red", [[2, 2]]))["break"]().caption("<b>Step 3b:</b> We divide by 10 to make it equal to 1.").rowMult(2, 1 / 10)["break"]().caption("Notice that the matrix is now in <i>row echelon form</i>.").setStyle([
  {
    color: "red",
    entries: [[0, 0], [1, 1], [2, 2]],
    duration: 1,
    color: "black",
    entries: [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]],
    duration: 1
  }
])["break"]().caption("To put the matrix in <i>reduced</i> row echelon form, we\nneed to clear the entries in\n<span style=\"color: blue;\">blue</span>.").setStyle([
  {
    color: "black",
    entries: [[0, 0], [1, 1], [2, 2]],
    duration: 1
  }
].concat(blink("blue", [[0, 1], [0, 2], [1, 2]], 1)))["break"]().caption("<b>Last step:</b>\nWe do this by taking advantage of the pivots in each column\nand doing row replacement.").setStyle(blink("red", [[1, 1], [2, 2]]))["break"]().caption("<b>Last step:</b> First we clear the third column...").setStyle([
  {
    color: "black",
    entries: [[0, 1], [1, 1]],
    duration: 1
  }
].concat(blink("red", [[2, 2]], 1)).concat(blink("blue", [[0, 2], [1, 2]], 1))).caption("<b>Last step:</b>\nFirst we clear the third column using row replacement.").rowRep(2, -2, 1).rowRep(2, -3, 0)["break"]().caption("<b>Last step:</b> Then we clear the second column...").setStyle([
  {
    color: "black",
    entries: [[0, 2], [1, 2], [2, 2]],
    duration: 1
  }
].concat(blink("red", [[1, 1]], 1)).concat(blink("blue", [[0, 1]], 1))).caption("<b>Last step:</b>\nThen we clear the second column in the same way.").rowRep(1, -2, 0)["break"]().caption("The matrix is now in reduced row echelon form!").setStyle([
  {
    color: "black",
    entries: [[1, 0], [2, 0], [2, 1], [0, 1]],
    duration: 1,
    color: "red",
    entries: [[0, 0], [1, 1], [2, 2]],
    duration: 1
  }
])["break"]().caption("Add back the divider...").reAugment().caption("Add back the divider, and we're done!").setStyle({
  transform: "rotate(360deg)",
  entries: [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]],
  duration: 1.5,
  timing: 'linear'
})["break"]();

document.querySelector(".my-turn button").onclick = function() {
  var den, entry, getOps, i, j, k, l, m, mat, matval, num, ops, opsval, ref, ref1, ref2, ref3, ref4, row, rows, str;
  mat = slideshow.states[0].matrix;
  rows = [];
  for (i = k = 0, ref = mat.length; 0 <= ref ? k < ref : k > ref; i = 0 <= ref ? ++k : --k) {
    row = [];
    for (j = l = 0, ref1 = mat[0].length; 0 <= ref1 ? l < ref1 : l > ref1; j = 0 <= ref1 ? ++l : --l) {
      entry = mat[i][j];
      ref2 = RRMatrix.approxFraction(entry), num = ref2[0], den = ref2[1];
      row.push(num + ((ref3 = den !== 1) != null ? ref3 : "%2F" + {
        den: ""
      }));
    }
    rows.push(row.join(","));
  }
  matval = rows.join(":");
  getOps = function(slide) {
    var m, ref4, ret;
    if (slide.slides) {
      ret = [];
      for (i = m = 0, ref4 = slide.slides.length; 0 <= ref4 ? m < ref4 : m > ref4; i = 0 <= ref4 ? ++m : --m) {
        ret = ret.concat(getOps(slide.slides[i]));
      }
      return ret;
    }
    if (slide.data.shortOp) {
      return [slide.data.shortOp];
    }
    return [];
  };
  ops = [];
  for (i = m = 0, ref4 = slideshow.currentSlideNum; 0 <= ref4 ? m < ref4 : m > ref4; i = 0 <= ref4 ? ++m : --m) {
    ops = ops.concat(getOps(slideshow.slides[i]));
  }
  opsval = ops.join(",");
  str = "rrinter.html?mat=" + matval + "&ops=" + opsval + "&cur=" + ops.length;
  if (augment != null) {
    str += "&augment=" + augment;
  }
  return window.open(str);
};


        });
    </script>
</body>
</html>

